<%@page contentType="text/html; charset=UTF-8" trimDirectiveWhitespaces="true" pageEncoding="UTF-8" %>
<html>
<head>
    <%@include file="/WEB-INF/include/include.jsp" %>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15>
                    <form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/system/corp/save" method="post">
                        <div class="layui-tab">
                            <%--<ul class="layui-tab-title">
                                <li><a href="${pageContext.request.contextPath}/system/corp/list">租户列表</a></li>
                                <li class="layui-this">租户新增</li>
                            </ul>--%>
                            <h3 class="page-header">租户新增</h3>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label"><font color="red">租户名称</font></label>
                                        <div class="layui-input-block">
                                            <input type="text" name="corpName" required lay-verify="required" placeholder="请输入租户名称" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label"><font color="red">租户登陆名</font></label>
                                        <div class="layui-input-block">
                                            <input type="text" id="loginCorpName" name="loginCorpName" required lay-verify="required" placeholder="请输入租户登陆名" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label"><font color="red">用户数</font></label>
                                        <div class="layui-input-block">
                                            <input type="number" name="useNum" required lay-verify="required" placeholder="请输入用户数" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label"><font color="red">网盘空间(MB)</font></label>
                                        <div class="layui-input-block">
                                            <input type="number" name="skyDriveSpace" required lay-verify="required" placeholder="请输入网盘空间(MB)" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">联系人</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="contacts" placeholder="请输入联系人" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">联系电话</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="phone" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" style="padding-left: 10px;">
                            <div class="layui-input-block">
                                <shiro:hasPermission name="corp:add">
                                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="corpSubmit">提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </shiro:hasPermission>
                                <a href="javascript:history.back();" class="layui-btn layui-btn-primary">返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.config({
        base: "/static/admin/modules/"
    }).use(['jquery','eleTree','form'], function(){
        var $ = layui.jquery;
        var form = layui.form;

        form.on('submit(corpSubmit)', function(data){
            var name = $("#loginCorpName").val();
            var isok = false;
            $.ajax({
                url:'${urlAdmin}/system/corp/checkName/' + name,
                async:true,
                dataType:'json',
                success:function(data,textStatus,jqXHR){
                    if (data.rs == false) {
                        layer.msg('租户登录名相同');
                    } else {
                        $("form").submit();
                    }
                },
                error:function(xhr,textStatus){
                    layer.msg('服务器错误');
                }
            })
            return false;
        });

    });
</script>
</body>
</html>